class background{
  constructor (ctx) {
    this.img = new Image()
    this.img.src = 'images/bg.jpg'
    this.ctx = ctx
    this.top =0
    this.speed = 1
  }
  draw () {
    this.top = this.top >= this.ctx.canvas.height ? 0 : this.top + this.speed
    this.ctx.drawImage(this.img, 0, this.top - this.ctx.canvas.height, this.ctx.canvas.width, this.ctx.canvas.height)
    this.ctx.drawImage(this.img, 0, this.top, this.ctx.canvas.width, this.ctx.canvas.height)
  }
}
export default background